package com.mall.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.mall.business.service.ITYqUserService;
import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.enums.BusinessType;
import com.mall.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mall.business.domain.TWallet;
import com.mall.business.service.ITWalletService;
import com.mall.common.core.page.TableDataInfo;

/**
 * 钱包明细Controller
 *
 * @author ruoyi
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/business/wallet")
public class TWalletController extends BaseController {
    @Autowired
    private ITWalletService tWalletService;




    /**
     * 查询钱包明细列表
     */
//@RequiresPermissions("business:wallet:list")
    @GetMapping("/list")
    public TableDataInfo list(TWallet tWallet) {
        startPage();
        List<TWallet> list = tWalletService.selectTWalletList(tWallet);
        return getDataTable(list);
    }

    /**
     * 导出钱包明细列表
     */
    //@RequiresPermissions("business:wallet:export")
    @Log(title = "钱包明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWallet tWallet) {
        List<TWallet> list = tWalletService.selectTWalletList(tWallet);
        ExcelUtil<TWallet> util = new ExcelUtil<TWallet>(TWallet.class);
        util.exportExcel(response, list, "钱包明细数据");
    }

    /**
     * 获取钱包明细详细信息
     */
    //@RequiresPermissions("business:wallet:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tWalletService.getById(id));
    }

    /**
     * 新增钱包明细
     */
    //@RequiresPermissions("business:wallet:add")
    @Log(title = "钱包明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWallet tWallet) {
        return toAjax(tWalletService.save(tWallet));
    }

    /**
     * 修改钱包明细
     */
    //@RequiresPermissions("business:wallet:edit")
    @Log(title = "钱包明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWallet tWallet) {
        return toAjax(tWalletService.updateById(tWallet));
    }

    /**
     * 删除钱包明细
     */
    //@RequiresPermissions("business:wallet:remove")
    @Log(title = "钱包明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tWalletService.removeByIds(Arrays.asList(ids)));
    }



}
